<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns active resources</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.get-required-files.html">« get_required_files</a></li>
      <li style="float: right;"><a href="function.getenv.html">getenv »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.info.html">PHP 选项/信息 函数</a></li>
    <li>Returns active resources</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.get-resources" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">get_resources</h1>
  <p class="verinfo">(PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">get_resources</span> &mdash; <span class="dc-title">Returns active resources</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.get-resources-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>get_resources</strong></span>(<span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$type</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type">array</span></div>

  <p class="para rdfs-comment">
   Returns an array of all currently active <span class="type">resource</span>s, optionally
   filtered by resource type.
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <span class="simpara">
    This function is meant for debugging and testing purposes. It is not supposed
    to be used in production environments, especially not to access or even manipulate
    resources which are normally not accessible (e.g. the underlying stream resource
    of <span class="classname"><a href="class.splfileobject.html" class="classname">SplFileObject</a></span> instances).
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.get-resources-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">type</code></dt>

     <dd>

      <p class="para">
       If defined, this will cause <span class="function"><strong>get_resources()</strong></span> to only
       return resources of the given type.
       <a href="resource.html" class="link">A list of resource types is available.</a>
      </p>
      <p class="para">
       If the <span class="type">string</span> <code class="literal">Unknown</code> is provided as
       the type, then only resources that are of an unknown type will be
       returned.
      </p>
      <p class="para">
       If omitted, all resources will be returned.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.get-resources-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an <span class="type">array</span> of currently active resources, indexed by
   resource number.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.get-resources-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">type</code> is nullable now.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.get-resources-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-564">
    <p><strong>示例 #1 Unfiltered <span class="function"><strong>get_resources()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$fp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">tmpfile</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">get_resources</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(1) {
  [1]=&gt;
  resource(1) of type (stream)
}
</pre></div>
    </div>
   </div>
   <div class="example" id="example-565">
    <p><strong>示例 #2 Filtered <span class="function"><strong>get_resources()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$fp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">tmpfile</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">get_resources</span><span style="color: #007700">(</span><span style="color: #DD0000">'stream'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">get_resources</span><span style="color: #007700">(</span><span style="color: #DD0000">'curl'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(1) {
  [1]=&gt;
  resource(1) of type (stream)
}
array(0) {
}
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.get-resources-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.get-loaded-extensions.html" class="function" rel="rdfs-seeAlso">get_loaded_extensions()</a> - 返回所有编译并加载模块名的 array</span></li>
    <li class="member"><span class="function"><a href="function.get-defined-constants.html" class="function" rel="rdfs-seeAlso">get_defined_constants()</a> - 返回所有常量的关联数组，键是常量名，值是常量值</span></li>
    <li class="member"><span class="function"><a href="function.get-defined-functions.html" class="function" rel="rdfs-seeAlso">get_defined_functions()</a> - 返回所有已定义函数的数组</span></li>
    <li class="member"><span class="function"><a href="function.get-defined-vars.html" class="function" rel="rdfs-seeAlso">get_defined_vars()</a> - 返回由所有已定义变量所组成的数组</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>